package com.yunquan.ohana.ui.main

import android.app.Application
import androidx.lifecycle.LifecycleOwner
import com.google.gson.Gson
import com.yunquan.ohana.base.bus.RxBus
import com.yunquan.ohana.base.bus.RxSubscriptions
import com.yunquan.ohana.base.bus.event.SingleLiveEvent
import com.yunquan.ohana.base.ui.BaseViewModel
import com.yunquan.ohana.entity.EventEntity
import com.yunquan.ohana.entity.EventType
import com.yunquan.ohana.entity.LoginEntity
import com.yunquan.ohana.http.BaseHttp
import com.yunquan.ohana.http.observer.BaseObserver
import com.yunquan.ohana.http.transformer.CommonTransformer
import com.yunquan.ohana.ui.bindDevice.BindDeviceActivity
import com.yunquan.ohana.utils.L
import com.yunquan.ohana.utils.SPUtils
import com.yunquan.ohana.utils.SystemUtils
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.disposables.Disposable
import okhttp3.RequestBody.Companion.toRequestBody

class MainViewModel(application: Application) : BaseViewModel(application) {

    val ui = SingleLiveEvent<Int>()

    override fun onEvent(event: EventEntity) {
        super.onEvent(event)
        if (event.type == EventType.AUTH_FAILED) {
            startActivity(BindDeviceActivity::class.java)
            finish()
        } else if (event.type == EventType.SEND_TO_FRAMES) {
            ui.value = 0
        }
    }
}